package com.szly.phm.admin.controller;

import com.szly.phm.admin.aspectj.annotation.OperationLogAnnotation;
import com.szly.phm.admin.aspectj.enums.ModuleEnum;
import com.szly.phm.admin.aspectj.enums.OperationActionEnum;
import com.szly.phm.admin.utils.CustomResponse;
import com.szly.phm.admin.utils.SecurityUtils;
import com.szly.phm.common.entity.dto.simulation.SimulationAlgorithmDTO;
import com.szly.phm.common.entity.dto.simulation.SimulationDTO;
import com.szly.phm.common.entity.dto.user.LoginUserDTO;
import com.szly.phm.common.entity.result.RootResponse;
import com.szly.phm.common.service.ISimulationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@Validated
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/pc/ta")
@Api(tags = "仿真中心")
public class SimulationController {
    private final ISimulationService iSimulationService;
    @ApiOperation(value = "数据仿真")
    @OperationLogAnnotation(getModuleName = ModuleEnum.TK_CODE,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/simulationData")
    @CustomResponse
    public RootResponse simulationData(@Valid @RequestBody SimulationDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iSimulationService.simulationData(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询数据仿真")
    @GetMapping("/v1/simulationData")
    @CustomResponse
    public RootResponse getSimulationData() {
        return iSimulationService.selectSimulationData();
    }
    @ApiOperation(value = "数据算法仿真")
    @OperationLogAnnotation(getModuleName = ModuleEnum.TK_CODE,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/simulationAlgorithmData")
    @CustomResponse
    public RootResponse simulationAlgorithmData(@Valid @RequestBody SimulationAlgorithmDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iSimulationService.simulationAlgorithmData(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询数据算法仿真")
    @GetMapping("/v1/simulationAlgorithmData")
    @CustomResponse
    public RootResponse getSimulationAlgorithmData() {
        return iSimulationService.selectSimulationAlgorithmData();
    }

    /**
     * @description : TODO
     * @param radarId
     * @return : com.szly.phm.common.entity.result.RootResponse
     * @author : git.jas0nch
     * date : 2022/3/12
     **/
    @ApiOperation(value = "查询数据仿真指定雷达的结果集")
    @GetMapping("/v1/simulationOfIndexResult")
    @CustomResponse
    public RootResponse getSimulationOfIndexResult(String radarId) {
        return iSimulationService.selectSimulationOfIndexResult(radarId);
    }

}
